<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户注册</title>
     <script src="js/jquery-1.12.4.js"></script>
     <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <form id="frm">
            帐号：<input type="text" v-model="name" name="name"><br/>
            密码：<input type="text" v-model="pass" name="pass"><br/>
            年龄：<input type="text" v-model="age" name="age"><br/>
            性别：<input type="radio" v-model="sex" name="sex" value="男">男
                <input type="radio" v-model="sex" name="sex" value="女">女
                <br/>
            <button type="button" @click="register">注册</button>
        </form>
    </div>

    <script>
        let vm=new Vue({
            el:'#app',
            data:{
                name:'zs',
                pass:'123456',
                sex:'女',
                age:18
            },
            methods:{
                register:function() {
                    $.ajax({
                        url: 'http://localhost:8080/ums/register.do',
                        type: 'post',
                        data: $("#frm").serialize(),
                        dataType: 'json',
                        success: function (responseData) {
                            if (responseData.code == 200) {
                                alert( responseData.msg )
                                window.location.href = "login.html";
                            } else {
                                alert( responseData.msg );
                            }
                        }
                    });
                }
            }
        }) ;

    
    </script>
</body>
</html>